#include <pic.h>
#include <stdio.h>


#include "common\lcd.h"
#include "common\DCI_Protocol.h"
#include "routines.h"
#include "common\Serial.h"
#include "interrupt.h"



//-------------------------------------------------------

extern const char* const Error_explanation[];
extern const char* const model_name[];


extern const char ITUHeader[4];
extern const char ITUPreset[6];
extern bank1 unsigned char ITUMsgId;

extern const char IDUHeader[4];
extern const char IDUPreset[20];
extern bank1 unsigned char IDUMsgId;


//--------------------------------------------------------

#define Tick 2500 
#define Debug_mode 10

//--------------------------------------------------------

extern bit  flag_system_tick;
extern bit  flag_pulse_tick;
extern bit	flag_packet_received;	 	
extern bit	flag_packet_good;
extern bit	flag_packet_sent;
extern bit	flag_com_pause;
extern bit	flag_rx_error;
extern bit 	flag_itu_start;

extern bit	flag_tout_enable;
extern bit  flag_packet_ready;

extern bit flag_show_debug;
extern bit flag_show_menu0;

extern bit flag_sequence_running;

extern bank2 unsigned char counter1, button;


//--------------------------------------------------------
#define RX_BUF_LENGHT 30
extern bank1 unsigned char rx_buf[RX_BUF_LENGHT];
extern  unsigned char rx_buf_index;
extern  unsigned char rx_buf_start;
extern  unsigned char rx_packet_lengt;
extern  unsigned char rx_byte_tout;
#define TX_BUF_LENGHT 28
extern bank2 unsigned char tx_buf[TX_BUF_LENGHT];
extern unsigned char tx_buf_index;
extern unsigned char tx_count;

extern unsigned char txrxpause;

typedef struct PresetType
{	unsigned char 	Compressor_freq;
	unsigned int 	EEV_value;
	unsigned char	Fan_speed;
	unsigned char	Mode;
};



typedef union t_UnVar  	
{
	float Float;	
	int Int;
	unsigned char UChar;
	signed char SChar;
	const char* STRING;
};

typedef const struct t_MinMaxInt
{
	const int Min;
	const int Max;
};

typedef const struct t_MinMaxUChar 
{
	const unsigned char Min;
	const unsigned char Max;
};

typedef const struct t_MinMaxSChar
{
	const signed char Min;
	const signed char Max;
};
typedef const struct t_MinMaxFloat
{
	const float Min;
	const float Max;
};

typedef const union t_UnLimit
{ 
	const struct t_MinMaxSChar* SChar;
	const struct t_MinMaxUChar* UChar;
	const struct t_MinMaxInt* Int;
};



typedef enum {invalid=0,Idu,Odu,kCOM,MSMP} en_group;
extern volatile en_group sourse,destination;


extern bank1 struct PresetType myPreset;
extern bank1 struct PresetType myEDPreset;
extern bank3 struct PresetType tempPreset;
extern unsigned char preset_index;
//----------------------------------------------------------

#include "sequence.h"
#include "error_list.h"
#include "DoTest.h"

extern bank3 int test_duration,rest_of_test,rest_of_stage;

//--------------------------------------------------------



extern bank1 union ComHeaderType MyODUIDUHeader;
extern bank1 union ComHeaderType MyIDUHeader;
extern bank1 union ComHeaderType MyODUkCOMHeader;
extern bank2 union ODUType MyODU;
extern bank2 union IDUType MyIDU;
extern bank2 union ITUType MyITU;
extern bank2 union ITUType MyITU_answer;
extern bank1 struct PresetType myPreset;
extern bank1 struct PresetType myAnswer;
extern unsigned char preset_index;

